// #include <fstream>
//
//
// #include "yolov7.h"
// #include "BYTETracker.h"
//
// bool detect_car_working(cv::Rect box1, cv::Rect box2) {
//	if (std::abs(box1.x - box2.x) > 10 || std::abs(box1.y - box2.y) > 10) {
//		return true;
//	}
//	else if (std::abs(box1.width - box2.width) > 10 || std::abs(box1.height - box2.height) > 10) {
//		return true;
//	}
//	else {
//		return false;
//	}
// }
//
// int main() {
//	//����yolo����
//	Net_config YOLOV7_nets = { 0.3, 0.7, "models/exp1best_640x640.onnx" };   ////choices=["models/yolov7_640x640.onnx", "models/yolov7-tiny_640x640.onnx", "models/yolov7_736x1280.onnx", "models/yolov7-tiny_384x640.onnx", "models/yolov7_480x640.onnx", "models/yolov7_384x640.onnx", "models/yolov7-tiny_256x480.onnx", "models/yolov7-tiny_256x320.onnx", "models/yolov7_256x320.onnx", "models/yolov7-tiny_256x640.onnx", "models/yolov7_256x640.onnx", "models/yolov7-tiny_480x640.onnx", "models/yolov7-tiny_736x1280.onnx", "models/yolov7_256x480.onnx"]
//	YOLOV7 net(YOLOV7_nets, "YOLOV7");
//	//����׷����
//	byte_track::BYTETracker* tracker = new byte_track::BYTETracker(15, 35);
//
//	cv::VideoCapture cap("videos/cam1-rotate.mp4");
//	cv::Mat src, dst;
//	cap >> src;
//
//	//������Ƶд�����
//	cv::VideoWriter writer;
//	writer.open("detect_hack_region.mp4", cv::VideoWriter::fourcc('H', '2', '6', '4'), 25, cv::Size(src.cols, src.rows));
//
//	std::unordered_map<int, cv::Rect> RT_car_map;
//	std::unordered_map<int, bool> RT_car_working_flag;
//	while (!src.empty()) {
//		int car_count = 0;
//		std::vector<BoxInfo> generate_boxes = net.detect(src);
//		std::vector<byte_track::Object> obj_vec;
//		for (auto& box : generate_boxes) {
//			if (box.label == 0)obj_vec.push_back(byte_track::Object(byte_track::Rect<float>(box.x1, box.y1, box.x2 - box.x1, box.y2 - box.y1), 0, box.score));
//		}
//		std::vector<byte_track::BYTETracker::STrackPtr> bytetrack_res = tracker->update(obj_vec);
//
//		for (const auto &outputs_per_frame : bytetrack_res)
//		{
//			const auto &rect = outputs_per_frame->getRect();
//			const auto &track_id = outputs_per_frame->getTrackId();
//			cv::Rect cv_rect(rect.tl_x(), rect.tl_y(), rect.width(), rect.height());
//			if (rect.tl_y() < 600) continue;
//			char str[256] = ""; /* In fact not necessary as snprintf() adds the
//			 0-terminator. */
//			snprintf(str, sizeof str, "%zu", track_id);
//			cv::rectangle(src, cv_rect, cv::Scalar(0, 255, 0));
//			std::string class_name = net.class_names[0];
//			std::string label = class_name + "_" + str;
//			int id = std::atoi(str);
//			if (RT_car_map.find(id) != RT_car_map.end()&& detect_car_working(cv_rect, RT_car_map[id])) {
//				RT_car_working_flag[id] = true;
//			}
//			if (RT_car_working_flag[id] == true) {
//				label = label + "_is_working";
//			}
//			else {
//				label = label + "_is_not_working";
//			}
//			cv::putText(src, label, cv::Point2f(cv_rect.x, cv_rect.y - 16), cv::FONT_HERSHEY_COMPLEX_SMALL, 1, cv::Scalar(255, 0, 0), 2);
//			RT_car_map[id] = cv_rect;
//			if(RT_car_working_flag.find(id) == RT_car_working_flag.end() &&
//				!RT_car_working_flag[id]) RT_car_working_flag[id] = false; //���г�ʼ��
//		}
//
//
//		//region_0.showRegion(src);
//		cv::namedWindow("12321", cv::WINDOW_NORMAL);
//		cv::resizeWindow("12321", 1800, 1350);
//		cv::imshow("12321",src);
//
//		cv::waitKey(1);
//		writer << src;
//		cap >> src;
//
//	}
//	cap.release();
//	writer.release();
//	return 0;
// }
